import "strings"

/*
 * @lc app=leetcode.cn id=14 lang=golang
 *
 * [14] 最长公共前缀
 */

// @lc code=start
func longestCommonPrefix(strs []string) string {
	if len(strs) == 0 {
		return ""
	}
	p := strs[0]
	for _, v := range strs {
		for !strings.HasPrefix(v, p) {
			p = p[:len(p)-1]
		}
	}

	return p
}

// @lc code=end

